﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;


/// <summary>
/// Summary description for CategoryDAO
/// </summary>
public class CategoryDAO:DBConnect
{
    string SQL_SELECT = "select * from categories";
   
	public CategoryDAO()
	{		
	}
    public IList<Category> Get_CategoryName()
    {
        IList<Category> list = new List<Category>();
            try{
            SqlCommand cmd = new SqlCommand(SQL_SELECT,conn);
            if (ConnectDB())
            {

                SqlDataReader rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    Category ct = new Category();
                    ct.Category_id = rd.GetInt32(0);
                    ct.Name = rd.GetString(1);
                    list.Add(ct);

                }
                Disconnect();
            }
                  
            }catch(SqlException e)
            {
                Disconnect();
            }
        return list;

    }
    
}